import request from "@/utils/request.js";
// import { useTokenStore } from "@/stores/token.js";

//文章列表分类查询
export const articleCategoryListService = () => {
    /* const tokenStore = useTokenStore();
    tokenStore.token;
    在pinia中定义的响应式数据都不需要.value
    return request.get('/category', { headers: { 'Authorization': tokenStore.token } }) */
    return request.get('/category',)//此时这个请求会被request中的请求拦截器拦截并添加token
}

//文章分类添加
export const ArticleCategoryAddService = (categoryData) => {//categoryData是JSON格式
    return request.post('/category', categoryData)
}

//文章分类修改
//在这里，categoryData被request.js自动转换为了JSON格式 
export const ArticleCategoryUpdateService = (categoryData) => {
    return request.put('/category', categoryData)
}

//文章分类删除
export const ArticleCategoryDeleteService = (id) => {
    return request.delete('/category?id=' + id)
}

//文章列表查询   ?param1=value1&param2=value2&param3=value3
export const articleListService = (params) => {
    return request.get('/article', { params: params })
}

//文章添加
export const ArticleAddService = (articleData) => {
    return request.post('/article', articleData);
}

//文章信息修改
export const ArticleUpdateService = (articleData) => {
    return request.put('/article', articleData)
}

//删除文章
export const ArticleDeleteService = (id) => {
    return request.delete('/article?id=' + id)
}
